<?php

namespace app\web\services;

use think\Service;
use think\facade\Request;
use app\web\model\ManualModel;

/**
 * @手册管理
 */
class ManualService extends Service
{
    protected $manualModel;
    public function __construct(Request $request = null)
    {
        parent::__construct($request);
        $this->manualModel = new ManualModel();
    }
    
    /**
     * @获取所有数据
     */
    public function getDataById(){
        $get = input('get.');
        if(empty($get['id'])){
            return '';
        }
        $where=[['status','eq',1],['id','eq',$get['id']]];
        $ruslt = $this->manualModel->selectById($where);
        $ruslt['contents'] = html_entity_decode($ruslt['contents'],ENT_QUOTES);
        return $ruslt;
    }
    
    /**
     * @模糊查询
     */
    public function getList(){
        $get = input('post.');
        if(empty($get['keyword'])){
            return '';
        }
        
        if(empty($get['pid'])){
            return '';
        }
        
        $where=[['contents|ManualModel.title','like','%'.$get['keyword'].'%'],['ManualGroupModel.pid','eq',$get['pid']]];
        
        $ruslt = $this->manualModel->selectLikeList($where);
        return $ruslt;
    }
    
    /**
     * @获取一级数据
     */
    public function getParentList(){
        $ruslt = $this->manualModel->selectParentList();
        return $ruslt;
        
    }
}